<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html >
<html>
	<head><title>注册页面</title>
	<script>
    function validate() {
    var pw1 = document.getElementById("pw1").value;
    var pw2 = document.getElementById("pw2").value;
    if(pw1 == pw2) {
    document.getElementById("tishi").innerHTML="";
    document.getElementById("submit").disabled = false;
    }
    else {
    document.getElementById("tishi").innerHTML="<font color='red'>两次密码输入不一致</font>";
    document.getElementById("submit").disabled = true;
    }
    }
</script>
<script type="text/javascript" src="dwr/engine.js"></script>
	<script type="text/javascript" src="dwr/util.js"></script>
	<script type="text/javascript" src="dwr/interface/UserDAOAjax.js"></script>
	<script type="text/javascript">
	
		function show(boolean){
			if(boolean){
				document.getElementById("tishi0").innerHTML="<font color='red'>用户名已经存在</font>";
				document.getElementById("submit").disabled = true;
			}
			else document.getElementById("submit").disabled = false;
		
		}
		function validate0(){
			var name=document.getElementById("name").value;
			if(name==""){
			
				document.getElementById("tishi0").innerHTML="<font color='red'>用户名不能为空</font>";
				document.getElementById("submit").disabled = true;
				return;
			}
			else document.getElementById("tishi0").innerHTML="";
			UserDAOAjax.exitUser(name,show);
		}
	</script>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="js/jquery.min.js"></script>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <script src="js/bootstrap.min.js"></script>
    <link href="css/signin.css" rel="stylesheet">
    </head>
	<body>
	<div class="container">
		<form class="form-signin" action="register.action" method="post" >
			<h2 class="form-signin-heading">用户注册</h2>
			<input type="text"  class="form-control" autofocus name="user.username" id="name" placeholder="用户名" size="20" onkeyup="validate0()" title="支持字母、数字、下划线的组合,4-20个字符"  required pattern="[A-Za-z0-9_]{4,20}"/><span id="tishi0"></span><br>
			<input type="password"  class="form-control" id="pw1" name="user.password" placeholder="密码"size="20" required title="密码长度至少为四位且只能由数字、字母组成,4-20个字符" pattern="[A-Za-z0-9]{4,20}" /><br>
			<input type="password"  class="form-control" id="pw2" placeholder="确认密码" onkeyup="validate()" required title="请再次输入密码" size="20"/><span id="tishi"></span><br>
			<input type="submit" class="btn btn-lg btn-primary btn-block" id="submit" value="立即注册"/>&nbsp;<a href="login.jsp">返回登录</a>
		</form></div>
	</body>
</html>